﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using LPY.LeHealth.DTO;

namespace LPY.LeHealth.DAL
{
    using ServiceStack.OrmLite;
   public  class Pnandal: GenericBaseDAL<PhysicalNan>
    {
      // PhysicalNan
       /// <summary>
       /// 根据类型显示详情
       /// </summary>
       /// <param name="pid"></param>
       /// <returns></returns>
       public List<Object> showxiang(int pid)
       {
           using (var cnn = DbConnection)
           {

               var rtv = cnn.From<PhysicalNan>()
                   .LeftJoin<PhysicalNan, PhysicalType>((t, u) => t.Pid == u.Id)
                   .Select<PhysicalNan, PhysicalType>((t, u) => new
                    {
                        t.Id,
                        t.Ptitle,
                        t.Pdate,
                        t.Pwang,
                        t.Pcontent,
                        u.PhysicalName
                    }).Where(m=>m.Pid==pid );

               return cnn.Select<object>(rtv);
           }
       }
       /// <summary>
       /// 显示体检指南的详细信息
       /// </summary>
       /// <returns></returns>
       public List<PhysicalNan> show()
       {
           using (var cnn = DbConnection)
           {
               
               var sql = cnn.From<PhysicalNan>()
                   .LeftJoin<PhysicalType>((t, u) => t.Pid == u.Id)
                   .Select<PhysicalNan,PhysicalType>((t, u) => new
                   {
                       t.Id,
                       t.Ptitle,
                       t.Pcontent,
                       t.Pwang,
                       t.Pdate,
                       t.Pid,
                       u.PhysicalName,
                   });
               return cnn.Select<PhysicalNan>(sql);
           }
       }
    }
}
